namespace TsCore.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class mig1 : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.Comments",
                c => new
                    {
                        CommentId = c.Int(nullable: false, identity: true),
                        CmtDate = c.DateTime(nullable: false),
                        Text = c.String(),
                    })
                .PrimaryKey(t => t.CommentId);
            
            CreateTable(
                "dbo.Fixtures",
                c => new
                    {
                        FixtureId = c.Int(nullable: false, identity: true),
                        Discriminator = c.String(nullable: false, maxLength: 128),
                    })
                .PrimaryKey(t => t.FixtureId);
            
            CreateTable(
                "dbo.Matches",
                c => new
                    {
                        MatchId = c.Int(nullable: false, identity: true),
                        Date = c.DateTime(nullable: false),
                        Name = c.String(),
                        HomeTeam_TeamId = c.Int(),
                        VisitorTeam_TeamId = c.Int(),
                    })
                .PrimaryKey(t => t.MatchId)
                .ForeignKey("dbo.Teams", t => t.HomeTeam_TeamId)
                .ForeignKey("dbo.Teams", t => t.VisitorTeam_TeamId)
                .Index(t => t.HomeTeam_TeamId)
                .Index(t => t.VisitorTeam_TeamId);
            
            CreateTable(
                "dbo.Teams",
                c => new
                    {
                        TeamId = c.Int(nullable: false, identity: true),
                        Name = c.String(),
                        Image = c.String(),
                        TsUser_TsUserId = c.Int(),
                    })
                .PrimaryKey(t => t.TeamId)
                .ForeignKey("dbo.TsUsers", t => t.TsUser_TsUserId)
                .Index(t => t.TsUser_TsUserId);
            
            CreateTable(
                "dbo.Sports",
                c => new
                    {
                        SportId = c.Int(nullable: false, identity: true),
                        Name = c.String(),
                    })
                .PrimaryKey(t => t.SportId);
            
            CreateTable(
                "dbo.TsUsers",
                c => new
                    {
                        TsUserId = c.Int(nullable: false, identity: true),
                        Name = c.String(),
                        Surname = c.String(),
                        Email = c.String(),
                        UserName = c.String(),
                    })
                .PrimaryKey(t => t.TsUserId);
            
            CreateTable(
                "dbo.AuditLog",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Date = c.DateTime(nullable: false),
                        Thread = c.String(maxLength: 255),
                        Level = c.String(maxLength: 50),
                        Logger = c.String(maxLength: 255),
                        Message = c.String(maxLength: 4000),
                        Exception = c.String(maxLength: 2000),
                    })
                .PrimaryKey(t => t.Id);
            
        }
        
        public override void Down()
        {
            DropIndex("dbo.Teams", new[] { "TsUser_TsUserId" });
            DropIndex("dbo.Matches", new[] { "VisitorTeam_TeamId" });
            DropIndex("dbo.Matches", new[] { "HomeTeam_TeamId" });
            DropForeignKey("dbo.Teams", "TsUser_TsUserId", "dbo.TsUsers");
            DropForeignKey("dbo.Matches", "VisitorTeam_TeamId", "dbo.Teams");
            DropForeignKey("dbo.Matches", "HomeTeam_TeamId", "dbo.Teams");
            DropTable("dbo.AuditLog");
            DropTable("dbo.TsUsers");
            DropTable("dbo.Sports");
            DropTable("dbo.Teams");
            DropTable("dbo.Matches");
            DropTable("dbo.Fixtures");
            DropTable("dbo.Comments");
        }
    }
}
